package com.fuint.common.service;

import com.fuint.common.vo.SybPayConfigVO;
import com.fuint.framework.exception.BusinessCheckException;
import com.fuint.framework.web.ResponseObject;
import com.fuint.repository.model.MtOrder;
import com.fuint.repository.model.MtUser;

import java.math.BigDecimal;

/**
 * 微信相关业务接口
 *
 * @author Tom
 * @since 2025/03/09
 */
public interface SybPayService {

    /**
     * 提交预支付订单（通联云闪付）
     *
     * @param userInfo   会员信息
     * @param orderInfo  订单信息
     * @param payAmount  支付金额
     * @param authCode   支付二维码
     * @param giveAmount 赠送金额
     * @param ip         支付发起IP
     * @param platform   支付平台
     * @return ResponseObject
     * @see ResponseObject
     */
    ResponseObject createPrepayOrder(MtUser userInfo, MtOrder orderInfo, Integer payAmount, String authCode, Integer giveAmount, String ip, String platform) throws BusinessCheckException;

    /**
     * 提交预支付订单（通联微信收银台）<br/>
     * 这种方式不在服务端请求接口，而是把参数拼接好后，由小程序段跳转到TL小程序完成支付<br/>
     * https://isv-test.allinpay.com/doc/978/
     *
     * @param userInfo   会员信息
     * @param orderInfo  订单信息
     * @param payAmount  支付金额
     * @param authCode   支付二维码
     * @param giveAmount 赠送金额
     * @param ip         支付发起ip
     * @param platform   支付平台
     * @return ResponseObject
     * @see ResponseObject
     */
    ResponseObject createPrepayOrderForWxCashier(MtUser userInfo, MtOrder orderInfo, Integer payAmount, String authCode, Integer giveAmount, String ip, String platform) throws BusinessCheckException;

    /**
     * 提交预支付订单（通联微信支付）
     *
     * @param userInfo   会员信息
     * @param orderInfo  订单信息
     * @param payAmount  支付金额
     * @param authCode   支付二维码
     * @param giveAmount 赠送金额
     * @param ip         支付发起ip
     * @param platform   支付平台
     * @return ResponseObject
     * @see ResponseObject
     */
    ResponseObject createPrepayOrderForWx(MtUser userInfo, MtOrder orderInfo, Integer payAmount, String authCode, Integer giveAmount, String ip, String platform) throws BusinessCheckException;

    /**
     * 获取支付配置
     *
     * @param storeId 店铺ID
     * @return SybPayConfigVO
     * @throws BusinessCheckException BusinessCheckException
     */
    SybPayConfigVO getConfig(Integer storeId) throws BusinessCheckException;

    /**
     * 发起售后退款
     *
     * @param storeId      店铺ID
     * @param orderSn      订单号
     * @param totalAmount  订单总金额
     * @param refundAmount 售后金额
     * @param platform     订单平台
     * @return Boolean
     */
    Boolean doRefund(Integer storeId, String orderSn, BigDecimal totalAmount, BigDecimal refundAmount, String platform) throws BusinessCheckException;
}
